<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-for</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>
<body>
    <div id="app">
        <input type="button" value="add data" @click="add">
        <input type="button" value="rm data" @click="remove">
        <ul>
            <li v-for="(item, index) in arr">
                {{index+1}}school:{{item}}
            </li>
        </ul>
        <h2 v-for="item in vegetables" v-bind:title="item.name">
            {{item.name}}
        </h2>

    </div>

    <script>
        var app = new Vue({
            el:"#app",
            data:{
                arr:["peking","shanghai","shenzhen","guangzhou"],
                
                // 对象数组
                vegetables:[
                    {name:"🥦"},
                    {name:"🍅"}
                ]               
            },
            methods:{
                    add:function(){
                        this.vegetables.push({name:"🌿"})
                    },
                    remove:function(){
                        this.vegetables.shift();
                    }
            }
        })
    </script>
    
</body>
</html>